<?php session_start(); ?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "tb_dailyrxinfo.php" ?>
<?php include "userfn50.php" ?>
<?php include "tb_usersinfo.php" ?>
<?php include "db.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	header("Location: login.php");
	exit();
}
?>



<?php require_once('Connections/MYCONN.php'); ?>
<?php
mysql_select_db($database_MYCONN, $MYCONN);

$query_Recordset1 = "SELECT DISTINCT UPPER(DATE_FORMAT(LogDate,'%M %Y')) as MonthYear FROM tb_cashlog WHERE logdate >=(CAse when (select Date(ControlDate) from tb_controlview where status ='Y') is null then 
			Date('2000-01-01 00:00:00')
		else
			(select Date(ControlDate) from tb_controlview where status ='Y')
		end) ORDER BY LogDate DESC ";
$Recordset1 = mysql_query($query_Recordset1, $MYCONN) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$num_rows = mysql_num_rows($Recordset1);

function getDetails( $groupid, $database_MYCONN, $MYCONN  )
{
	mysql_select_db($database_MYCONN, $MYCONN);
	$query_Recordset2 = "SELECT UPPER(DATE_FORMAT(LogDate,'%M %Y')) as MonthYear, t.ID, 				CONCAT(Date(LogDate),'::',upper(u.UserName),'::',r.RegisterID) as Link 
	FROM tb_cashlog t, tb_users u, tb_register r
	WHERE t.UserID = u.ID 
	AND t.RegisterID = r.ID 
	AND logdate >=(CAse when (select Date(ControlDate) from tb_controlview where status ='Y') is null then 
			Date('2000-01-01 00:00:00')
		else
			(select Date(ControlDate) from tb_controlview where status ='Y')
		end)
	AND DATE_FORMAT(LogDate,'%M %Y') = '".$groupid."' 
	ORDER BY t.LogDate DESC ";
	$Recordset2 	= mysql_query($query_Recordset2, $MYCONN) or die(mysql_error());
	$row_Recordset2 = mysql_fetch_assoc($Recordset2);

	echo "<TABLE class='Details'><TR><TD nowrap><UL>";
	do {
		echo "<LI>";
		echo "<a class='Hist' href=".chr(34)."ActivityLog3.php?ID=".addslashes(html_entity_decode(base64_encode($row_Recordset2['ID'])))."".chr(34)."  >".strtoupper($row_Recordset2['Link'])."</a>";
		
		echo "</LI>";
	} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); 
	echo "</UL></TD></TR></TABLE>";
}

?>
<?php include ("header.php") ?>


<title>Cash Log Entries History</title>

<style>
.inner_table
{
border-bottom:#CCCCCC 1px solid;
border-left:#CCCCCC 1px solid;
border-right:#CCCCCC 1px solid;

}
li{
font-size:xx-small;
list-style:circle;
margin-left:1;
}
.Header
{
    FONT-WEIGHT: bold;
    COLOR: #FFFFFF;
    FONT-FAMILY:Verdana, Arial, Helvetica, sans-serif;
	font-size:8pt;
    BACKGROUND-COLOR:#6699CC;
}

.Details
{
    BACKGROUND-COLOR:#CCCCCC;
}

.Hist:A
{
    TEXT-DECORATION: none;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:8px;

}
.Hist:A:link
{
    COLOR:#000033;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:8px;
}
.Hist:A:visited
{
    COLOR:#000033;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:8px;
}
.Hist:A:hover
{
	COLOR:#FF0000;
	TEXT-DECORATION:overline underline;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:8px;

}
.Hist:A:active
{
    COLOR: red;
    TEXT-DECORATION: underline;
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:8px;
	
}
</style>
<script language="javascript1.2">
function openWindow(url)
{
    var w = window.open (url, "win", "height=400,width=800,location=no,menubar=no,resizable,scrollbars=no,status=no,toolbar=no");
}
</script>
<p style="font-weight: bold">View Cash Log History</p>
	<table  bgcolor="#CECECE"  border="1" align="center" hspace="0" vspace="0" valign="center" width="600" cellpadding="0" cellspacing="10">
	<?php 
	$i=$num_rows ;
	$tr_start = "<tr bordercolor='#000000' class=".chr(34)."Header".chr(34).">";
	$tr_end = "</tr>";
	$j=round($i/4);
	$x=1;
	//echo $j;
	do {
		if ($x==1){
		echo $tr_start;
		}
		echo "<td width='100%'  valign='top' nowrap>";
		echo strtoupper($row_Recordset1['MonthYear']); 
		getDetails( $row_Recordset1['MonthYear'], $database_MYCONN, $MYCONN  );
		echo "</td>";
		if ($x==4){
		echo $tr_start;
		$x=0;
		}
	$x=$x+1;
	} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
	</table>

<?php include ("footer.php") ?>

<?php
mysql_free_result($Recordset1);
//mysql_free_result($Recordset2);
?>
